home *** CD-ROM | disk | FTP | other *** search
/ The Arsenal Files 8 / The Arsenal Files Collection #8 (Arsenal Computer) (1996).ISO / g_quake / ultqsrc.zip / CORPSE.QC < prev    next >
Text File  |  1996-10-02  |  6KB  |  198 lines

  1. /*
  2.  * Corpse-related material
  3.  * By AsmodeusB
  4.  * It's a solid corpse which can be gibbed, and moved (by running into it).
  5.  * Also, it falls down if you push it off a cliff. ;)
  6.  */
  7. .float floatlevel;
  8. void() CorpsePain =
  9. {
  10.  SpawnMeatSpray (self.origin, crandom() * 100 * v_right);
  11. };
  12.  
  13. void() CorpseMove = 
  14. {
  15.  
  16. if(other.takedamage != DAMAGE_AIM)     // not living
  17.  {
  18.         self.velocity = '0 0 0';
  19.         return;
  20.  }
  21. if(other.archtime > time&&other.charmed<10)
  22. {
  23. local entity summoned;
  24. summoned = spawn();
  25. summoned.charmed = TRUE;
  26. summoned.controller = other;
  27. summoned.oldenemy = other;
  28. if (other.enemy != world && other.enemy.alive)
  29.         summoned.enemy = other.enemy;
  30. else summoned.enemy = world;
  31. other.charmed = other.charmed + 1;
  32. summoned.follow = FALSE;
  33. summoned.think = self.initthink;
  34. setorigin(summoned, self.origin + v_up*16);
  35.         MagicEffect(summoned);
  36. summoned.nextthink = time + 1;
  37. remove(self);
  38. }
  39.  
  40. if (other.classname == "corpse")
  41. {
  42.  self.velocity_x = other.velocity_x;
  43.  self.velocity_y = other.velocity_y;
  44. }
  45. else
  46. {
  47.  self.velocity_x = other.velocity_x/3;
  48.  self.velocity_y = other.velocity_y/3;
  49.  if (other.classname == "player" && self.origin_z > other.origin_z && other.velocity_z > 0)
  50.         self.velocity_z = other.velocity_z;
  51. self.velocity = self.velocity + '0 0 7';
  52. }
  53.  
  54. if (self.flags & FL_ONGROUND)
  55.   self.flags = self.flags - FL_ONGROUND;
  56.  
  57. if (self.floating)
  58.         self.floatlevel = (random() * 4) + 12;
  59. };
  60.  
  61. void() CorpseDie =
  62. {
  63.  local float i;
  64.  local float j;
  65.  
  66.  sound (self, CHAN_VOICE, "player/udeath.wav", 1, ATTN_NORM);
  67.  // MakeSolidCorpse() sets netname to the head model
  68.  ThrowSolidHead (self.netname, self.health, self.classname);
  69.  i = 0;
  70.  while(i<3)
  71.  {
  72.   j = random();
  73.   if(j > 0.6)
  74.     ThrowGib ("progs/gib3.mdl", self.health);
  75.   else if(j > 0.3)
  76.     ThrowGib ("progs/gib3.mdl", self.health);
  77.   else
  78.     ThrowGib ("progs/gib3.mdl", self.health);
  79.   i = i + 1;
  80.  }
  81. };
  82.  
  83. void() CorpseOnlyDie =
  84. {
  85.  local float i;
  86.  local float j;
  87.  
  88.  sound (self, CHAN_VOICE, "player/udeath.wav", 1, ATTN_NORM);
  89.  // MakeSolidCorpse() sets netname to the head model
  90.  ThrowSolidHead (self.netname, self.health*5, self.frommonname);
  91.  i = 0;
  92.  while(i<3)
  93.  {
  94.   j = random();
  95.   if(j > 0.6)
  96.     ThrowGib ("progs/gib3.mdl", self.health*5);
  97.   else if(j > 0.3)
  98.     ThrowGib ("progs/gib3.mdl", self.health*5);
  99.   else
  100.     ThrowGib ("progs/gib3.mdl", self.health*5);
  101.   i = i + 1;
  102.  }
  103. };
  104.  
  105. void () CorpseThink =
  106. {
  107. local float cbob_z, cbob_x, cbob_y;
  108.         if ((self.watertype == CONTENT_WATER) || (self.watertype == CONTENT_SLIME))
  109.         {
  110.                 self.floating = TRUE;
  111.                 setsize (self, '-16 -16 0', '16 16 12');
  112.                 self.origin_z = self.origin_z + 8;
  113.                 if (!(self.flags & FL_ONGROUND))
  114.                         self.flags = self.flags + FL_ONGROUND;
  115.                 self.hite = self.origin_z;
  116.         }
  117.         else if (self.floating)
  118.                 {
  119.                 if (self.origin_z < self.hite + self.floatlevel)
  120.                         self.origin_z = self.origin_z + 1;
  121.                 else if ( (self.origin_z >= self.hite + self.floatlevel) && (random() > 0.7) )
  122.                         self.origin_z = self.origin_z - (random() * 10)/4;
  123.                 if (random() > 0.5)
  124.                         {
  125.                         cbob_z = self.angles_z + (random()*14) - 7;
  126.                         if (cbob_z > 7)                        
  127.                                 cbob_z = 7;
  128.                         if (cbob_z < -7)                        
  129.                                cbob_z = -7;
  130.                         self.angles_z = cbob_z;
  131.                         }
  132.                 if (random() > 0.5)
  133.                         {
  134.                         cbob_x = self.angles_x + (random()*14) - 7;
  135.                         if (cbob_x > 7)                        
  136.                                 cbob_x = 7;
  137.                         if (cbob_x < -7)                        
  138.                                 cbob_x = -7;
  139.                         self.angles_x = cbob_x;
  140.                         }
  141.                 if (random() > 0.5)
  142.                         {
  143.                         cbob_y = self.angles_y + (random()*14) - 7;
  144.                         if (cbob_y > 7)
  145.                                 cbob_y = 7;
  146.                         if (cbob_y < -7)                        
  147.                                 cbob_y = -7;
  148.                         self.angles_y = cbob_y;
  149.                         }        
  150.                 if (random() > 0.5)
  151.                         self.origin_x = self.origin_x + (random () * 4 - 2);
  152.                         self.origin_y = self.origin_y + (random () * 4 - 2);
  153.                 }
  154. if (self.alivetime < time||self.watertype==CONTENT_LAVA)
  155.         T_Damage(self,self,self,self.health);
  156. self.think = CorpseThink;
  157. self.nextthink = time + 0.5;
  158. };
  159.  
  160. /*
  161.  * This uses entity.netname to hold the head file (for CorpseDie())
  162.  * hack so that we don't have to set anything outside this function.
  163.  */
  164.  
  165. void(string headmdl, string frommon) MakeSolidCorpse =
  166. {
  167. // Make a gibbable corpse, change the size so we can jump on it
  168.         self.th_stand = SUB_Null;
  169.     self.th_walk = SUB_Null;
  170.     self.th_run = SUB_Null;
  171.     self.th_pain = CorpsePain;
  172.     self.th_melee = SUB_Null;
  173.     self.th_missile = SUB_Null;
  174.         self.th_die = CorpseOnlyDie;
  175.     self.touch = CorpseMove;
  176.         self.beendead = TRUE;
  177.         self.health = 25;
  178. // DAMAGE_AIM so that grenades don't bounce off like they do for DAMAGE_YES
  179.     self.takedamage = DAMAGE_AIM;
  180.     self.solid = SOLID_BBOX;
  181.     self.movetype = MOVETYPE_STEP;
  182.         setsize (self, '-16 -16 -23', '16 16 -3');
  183.         if (self.flags & FL_ONGROUND)
  184.                 self.flags = self.flags - (self.flags & FL_ONGROUND);
  185.         self.flags = self.flags & (!FL_MONSTER);
  186.         self.classname = "corpse";
  187.         self.alive = FALSE;
  188.         self.charmed = FALSE;
  189.         self.controller = self;
  190.         self.active = 0;
  191.     self.netname = headmdl;
  192.         self.floatlevel = (random()* 4) + 12;
  193.         self.frommonname = frommon;
  194.         self.onfire = FALSE;
  195.         self.alivetime = time + (random()*10) + 55; // decompose after 1 minute
  196.         CorpseThink();
  197. };
  198.